import tensorflow as tf
import numpy as np

def pb_to_txt():
    graph_def = tf.get_default_graph().as_graph_def()
    tf.io.write_graph(graph_def, "./export_graph ", 'graph.txt', as_text=True)

a = tf.Variable(initial_value=np.random.randn(32, 4, 8), dtype=tf.float32)

b = tf.Variable(initial_value=np.random.randn(32, 32, 8), dtype=tf.float32)

c = tf.matmul(a, b, transpose_b=True)

grads_and_vars = tf.gradients(c, [b])

b =  tf.get_default_graph().get_operation_by_name("gradients/MatMul_grad/Reshape_1")
print(b)
